﻿@using DistanceLearning.Models
@using System.Collections.Generic
@model dynamic

@{
    var ajaxOptions = new AjaxOptions()
                          {
                              HttpMethod = "POST",
                              InsertionMode = InsertionMode.Replace,
                              UpdateTargetId = "schoolListBlock",
                          };
}

<h2>Управление базами данных</h2>

<div id="schoolListBlock">
    @Html.Partial("_SchoolList", (IEnumerable<SchoolDetails>)ViewBag.SchoolList)
</div>

@Html.ActionLink("Добавить новую школу", "AddNewSchool")
<hr />
<h3>Администраторы учебных заведений</h3>
@{
    var profileOptions = new AjaxOptions()
                             {
                                 HttpMethod = "POST",
                                 InsertionMode = InsertionMode.Replace,
                                 Url = Url.Action("AddUserToRole", "Settings"),
                                 UpdateTargetId = "adminProfiles"
                             };
}

@using (Ajax.BeginForm(profileOptions))
{
    <div id="adminProfiles">
        @{
            Html.RenderPartial("_UserProfiles", ViewBag.SchoolAdminProfiles as IEnumerable<UserProfile>);
        }
    </div>
    
    @Html.DropDownList("userProfileId", new SelectList(ViewBag.UserProfiles, "UserId", "UserName"))
    <input type="submit" value="Добавить" />
}
